import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'

// 引入ElementPlus和样式
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

// 引入自定义样式
import './styles/index.less'

// 引入路由
import router from './router'

// 创建 Pinia 实例
const pinia = createPinia()
// 使用持久化插件
pinia.use(piniaPluginPersistedstate)

const app = createApp(App)

// 注册ElementPlus图标组件
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
    app.component(`ElIcon${key}`, component)
}

// 注册ElementPlus
app.use(ElementPlus)

// 注册路由
app.use(router)

// 注册Pinia
app.use(pinia)

app.mount('#app')
